function [c, t] = selectAllBlock(inpath, mode, param1)
% [c, t] = selectAllBlock(inpath, target)
% input:
%   inpath : input file (JPEG)
%   mode : following value
%       'single': 
%           param1 : range (for example, 0.97 for 97%)
%       'apply':
%           param1 : 8x8 matrix of T.
% output:
%   c : a 8x8 size cell of structs.
%       each struct s has:
%          s.h : histogram
%          s.t : T
    img = jpeg_read(inpath);
    coef = img.coef_arrays{1};
    clear img;
    c = cell(8,8);
    t = zeros(8,8);
    %% single mode
    if strcmp('single',mode) == 1
        target = param1;
        for bx=1:8
            for by=1:8
                [h,T]=selectOneBlock(coef, bx, by, target);
                c{bx,by} = h;
                t(bx,by) = T;
            end
        end
    end
    %% apply mode
    if strcmp('apply',mode) == 1
        t = param1;
        for bx=1:8
            for by=1:8
                h = applyOneBlock(coef, bx, by, t(bx,by));
                c{bx,by} = h;
            end
        end
    end
    clear coef; 
end
